<?php

namespace App\Home\Middleware;

use App\Exceptions\BaseException;
use Closure;
use App\Home\Utils\Home;
use Illuminate\Support\Facades\Auth;
use Illuminate\Auth\Middleware\Authenticate as Middleware;

class Authenticate extends Middleware
{
    public function handle($request, \Closure $next, ...$guards)
    {
        if (config()->get('app.env')=='production' && !session()->get('users')) {
            throw new BaseException("users Unauthenticated.", 401);
        }
        $request->user = session()->get('users');
        return $next($request);
    }
}
